import Vue from 'vue';
import Toast from './ch-showtoast.vue';

const ToastConstructor = Vue.extend(Toast); //注册实例
let toastInstance = null;
/**
 * @description 自定义反馈
 * @param {object} options - 参数对象
 *  @property {string} text - 文字内容
 *  @property {number} type = [1|2] - 展示类型：1 正确；2 错误
 */
const ShowToast = (options = {}) => {
	if(toastInstance == null){
		toastInstance = new ToastConstructor().$mount();//挂载实例
		document.body.appendChild(toastInstance.$el);
		toastInstance.load(options)
	}else{
		toastInstance.load(options)
	}
}

export default ShowToast